/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jhu.profiteer.data;

import java.io.Serializable;
import javax.persistence.Embeddable;

/**
 *
 * @author Jeremy
 */
@Embeddable
public class LocationCommodityPK implements Serializable
{
  private static final long serialVersionUID = 1L;
  private Long locationId;
  private Long commodityId;

  public LocationCommodityPK() {}
  public LocationCommodityPK(Long locationId, Long commodityId)
  {
    this.locationId = locationId;
    this.commodityId = commodityId;
  }

  /**
   * @return the locationId
   */
  public Long getLocationId() {
    return locationId;
  }

  /**
   * @param locationId the locationId to set
   */
  public void setLocationId(Long locationId) {
    this.locationId = locationId;
  }

  /**
   * @return the commodityId
   */
  public Long getCommodityId() {
    return commodityId;
  }

  /**
   * @param commodityId the commodityId to set
   */
  public void setCommodityId(Long commodityId) {
    this.commodityId = commodityId;
  }

  @Override
  public boolean equals(Object object)
  {
    if(!(object instanceof LocationCommodityPK)) return false;
    LocationCommodityPK other = (LocationCommodityPK)object;
    if ((null == this.getLocationId() && null != other.getLocationId()) ||
        (null != this.getLocationId() &&
         !this.locationId.equals(other.locationId))) {
      return false;
    }
    if ((null == this.getCommodityId() && null != other.getCommodityId()) ||
        (null != this.getCommodityId() &&
         !this.commodityId.equals(other.commodityId))) {
      return false;
    }
    return true;
  }

  @Override
  public int hashCode() {
    int hash = 0;
    hash += (null != getLocationId() ? getLocationId().hashCode() : 0) +
            (null != getCommodityId() ? getCommodityId().hashCode() : 0);
    return hash;
  }

  @Override
  public String toString() {
    return "jhu.profiteer.data.LocationCommodityPK[locationId=" +
            getLocationId() + ", commodityId=" + getCommodityId() + "]";
  }
}
